<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .active{
      color: pink;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- 1. 父给子传值 -->
    <son v-bind:arr="list">
      <!-- 2. 作用域插槽 -->
      <template v-slot="obj">
        <span :class="{active: obj.test === 'r'}">{{obj.test}}</span>
      </template>
    </son>
  </div>
  <script src="./vue.js"></script>
  <script>
    Vue.component('son', {
      props: ['arr'],
      template: `<div>
        <h2>我是son组件</h2>
        <ul>
          <li v-for="item in arr" :key="item">
            <slot :test="item"></slot>
          </li>
        </ul>
      </div>`
    })
    
    new Vue({
      el: '#app',
      data: {
        list: ['q', 'w', 'e', 'r']
      }
    })
  </script>
</body>
</html>